package com.wll.mapper.impl;

import com.wll.entity.Student;

import java.util.List;

/**
 * @ClassName: StudentProvider.java
 * @author: wanglulu
 * @version: 1.0.0
 * @Description: TODO
 * @createTime: 2021/11/22 13:39
 */
public class StudentProvider {


    /**
     * 拼接 sql
     * @param list
     * @return
     */
    public String insertListSql(List<Student> list) {
        StringBuffer sqlList = new StringBuffer();
        sqlList.append(" INSERT INTO student(name, age,sex, cid, cardId)  VALUES ");
        for (int i = 0; i < list.size() ; i++) {
            Student student = list.get(i);
            sqlList.append(" (")
                    .append("'").append(student.getName()).append("'").append(",")
                    .append(student.getAge()).append(",")
                    .append(student.getSex()).append(",")
                    .append(student.getCid()).append(",")
                    .append(student.getCardid())
                    .append(")");
            if (i < list.size()-1) {
                sqlList.append(",");
            }
        }
        return sqlList.toString();
    }

}
